Skip to content

Conversation

@georginahalpern
Copy link

  • Update dependency to es6 and more recent babylon version
  • Update imports to avoid import * from BABYLON
  • Update gltfLoader to use module-level gltfloader ImportFileAsync (to enable treeshaking)
  • Update gltfLoader to detect plugin extension vs hardcode glb
  • Integrate babylon observables into add/remove event listeners

Copy link
Contributor

@gkjohnson gkjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks! Just a few small changes and questions. I'll fix some of the lint errors in the other branch - looks like the CI only runs on PR into master.

@@ -1,4 +1,4 @@
import * as BABYLON from 'babylonjs';
import { Scene, Engine, Vector3, ArcRotateCamera } from '@babylonjs';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to import from @babylonjs/core?

Comment on lines +19 to +41
/**
* Detect if buffer contains GLB binary data by checking magic bytes
* @param {ArrayBuffer|Uint8Array} buffer - The file buffer
* @returns {boolean} True if GLB format
*/
isGLB( buffer ) {

// Handle both ArrayBuffer and typed arrays (e.g., Uint8Array)
const arrayBuffer = buffer instanceof ArrayBuffer ? buffer : buffer.buffer;
const byteOffset = buffer instanceof ArrayBuffer ? 0 : buffer.byteOffset;
const byteLength = buffer.byteLength;

if ( byteLength < 4 ) {

return false;

}

const view = new DataView( arrayBuffer, byteOffset, byteLength );
const magic = view.getUint32( 0, true ); // little-endian
return magic === GLB_MAGIC;

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure: there's no way for Babylon to determine whether a file is a binary or ascii glTF automatically?

Comment on lines -94 to +95
"babylonjs": "^7.0.0",
"babylonjs-loaders": "^7.0.0",
"@babylonjs/core": "^8.39.3",
"@babylonjs/loaders": "^8.39.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the "peerDependencies" section, too. I'll let you decide which versions are needed for the current babylon support but >=8.0.0 seem reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants